<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\model\Config;

class ConfigController extends Controller
{
    /**
     * 加载配置
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //获取数据
        $config = Config::first();
        
        return view('admin.ll.config.index',['conf'=>$config]);
    }

    /**
     * 修改配置信息
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //获取配置信息
        $config = Config::find($id);

        return view('admin.ll.config.edit',['conf'=>$config]);
    }

    //    文件上传
    public function upload(Request $request)
    {
//        获取文件对象
        $file = Input::file('file_upload');
//        判断文件是否有效
        if($file->isValid()){
            $entension = $file->getClientOriginalExtension();//上传文件的后缀名
            $newName = date('YmdHis').mt_rand(1000,9999).'.'.$entension;
            $path = $file->move(public_path().'/admin/images',$newName);
            $filepath = 'admin/images/'.$newName;
            return  $filepath;
        }
    }

    public function update(Request $request,$id){

    }
}
